/*
 * @Author: wangkun
 * @Date: 2021-08-19 05:46:50
 * @LastEditTime: 2021-08-19 07:03:58
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /user_demo_so_exe/demo_exe_dl.c
 */
#include <dlfcn.h>
#include <stdio.h>

int main(int argc, char* argv[]) {
    void* lib_handle = NULL;
    void (*test_b_ptr)(void);
    char* error_info;
    
    lib_handle = dlopen("libdemo.so", RTLD_LAZY);

    if (!lib_handle) {
        printf("libdemo.so open failed");
        return 0;
    }

    test_b_ptr = dlsym(lib_handle, "test_b");
    if (test_b_ptr) {
        printf("explicit load demo_so start\n");

        (*test_b_ptr)();

        printf("load demo_so end\n");
    }

    dlclose(lib_handle);
}